<template>
  <view>
    <button @click="login">登录</button>
    <button @click="createProject">新建项目</button>
  </view>
</template>

<script>
import cloudApi from "../../utils/cloudApi";
export default {
  data() {
    return {};
  },
  methods: {
    login() {
      cloudApi
        .call({
          type: "users/login",
          data: {
            phonenumber: "12345",
            password: "1234",
          },
        })
        .then((res) => {
          uni.setStorageSync("TOKEN", res.token);
          uni.showToast({
            title: "登录成功",
            icon: "success",
            mask: true,
          });
        });
    },
    createProject() {
      cloudApi
        .call({
          type: "projects/add",
          data: {
            name: "测试项目",
            tel: "22222222222",
            price: 21111,
            images: [
              "https://ops.c360dn.com/Camera360/03b1348f97e3e38b90b2a5fe73a66e2a.png",
              "https://ops.c360dn.com/Camera360/a04c97daf73ab5b656f4a06f4d7327f0.png",
              "https://ops.c360dn.com/Camera360/eae8632edb1283b8787b199b2c91bba7.png",
              "https://ops.c360dn.com/Camera360/4f53c5c275f262e289619ca5438e1807.png",
            ],
            rooms: [
              {
                name: "room1",
                totalPrice: 111,
                place: [
                  {
                    width: 1.2,
                    height: 2.2,
                    price: 40,
                  },
                ],
              },
              {
                name: "room12",
                totalPrice: 333,
                place: [
                  {
                    width: 13.2,
                    height: 12.2,
                    price: 60,
                  },
                ],
              },
            ],
          },
        })
        .then((res) => {
          uni.showToast({
            title: "新建成功",
            icon: "success",
            mask: true,
          });
        });
    },
  },
};
</script>

<style lang="scss"></style>
